/*
 * 2005-11-27 lxm 创建。 
 */
package com.hd123.rumba.util;

import java.io.Serializable;

/**
 * @author lxm
 * 
 * 消息表<br>
 * 用于向Web Service客户端返回消息
 */
public class DMessageMap implements Serializable {

  public static String VALUE_TYPE_ERROR = ClassifiedHashtable.ERROR;
  public static String VALUE_TYPE_WARN = ClassifiedHashtable.WARN;
  public static String VALUE_TYPE_INFO = ClassifiedHashtable.INFO;

  private DMessage[] messages;
  
  /**
   * 将一个ClassifiedHashtable赋值给本对象。<br>
   * 
   * @param h
   */
  public void assignFrom(ClassifiedHashtable h) {
    if (h == null) {
      messages = new DMessage[0];
      return;
    }
    Object[] keys = h.keySet().toArray();
    messages = new DMessage[keys.length];
    for (int i = 0; i < keys.length; i++) {
      DMessage msg = new DMessage();
      msg.setKey((String) keys[i]);
      ClassifiedHashtable.Entry entry = (ClassifiedHashtable.Entry) h.get((String) keys[i]);
      msg.setType(entry.getType());
      msg.setMessage(entry.getMessage());
      messages[i] = msg;
    }
  }

  public DMessage[] getMessages() {
    return messages;
  }

  public void setMessages(DMessage[] messages) {
    this.messages = messages;
  }


}
